<template>
  <div class="dialog-container">
    <el-dialog
      title="新增"
      :visible.sync="dialogVisible"
      custom-class="custom-dialog"
      width="70%"
      :before-close="handleClose"
      @opened="initData"
    >
      <el-form
        ref="form"
        class="query-more-form formTop"
        size="mini"
        label-width="85px"
        :model="form"
      >
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="适用节点">
              <el-input
                class="search-ipt"
                placeholder="请输入适用节点"
                maxlength="255"
                v-model="form.nodeCode"
              />
            </el-form-item>
          </el-col>

          <el-col :span="6">
            <el-form-item label="适用部门">
              <el-input
                class="search-ipt"
                placeholder="请输入适用部门"
                maxlength="255"
                v-model="form.deptId"
              />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="24">
            <el-input
              type="textarea"
              :rows="15"
              placeholder="请输入新增意见"
              v-model="form.opinion"
            >
            </el-input>
          </el-col>
        </el-row>

        <el-form-item>
          <div align="center" class="buttomBtn">
            <el-button class="submit" type="primary" @click="submit('form')"
              >提交</el-button
            >
          </div>
        </el-form-item>

        <!-- <el-input readonly type="textarea" v-model="content"></el-input> -->
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import { quillEditor } from "vue-quill-editor";
import { addOpinion } from "@/api/knowledgeBase.js";
import KnowledgeDialog from "@/views/system/components/knowledgeDialog";
import SourceDepartment from "@/views/system/components/SourceDepartment";
import "quill/dist/quill.core.css";
import "quill/dist/quill.snow.css";
import "quill/dist/quill.bubble.css";
// import "@/quill-editor.css";
import data from "@/views/pdf/content";
export default {
  name: "KnowledgeDetailsDialogAdd",
  components: {
    quillEditor,
    KnowledgeDialog,
    SourceDepartment,
  },
  props: {
    dialogVisible: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      data: {},
      content: "",
      editorOption: {
        placeholder: "编辑内容",
      },
      form: {},
      industryArr1: [],
      industryArr2: {},
      categorySupName: [],
      categorySubName: [],
      ThreeTypeDialogVisible: false,
      dispatchDialogVisible: false,
    };
  },
  created() {},
  mounted() {},
  methods: {
    initData() {},
    handleClose() {
      this.$emit("closeDialog");
    },

    submit(form) {
      this.$refs[form].validate((valid) => {
        if (!this.form.opinion) {
          this.$message.error("请输入要添加的常用意见");
          return;
        } else if (valid) {
          addOpinion(this.form).then((result) => {
            console.log(result);
            let { code, msg } = result;
            if (code == 200) {
              this.$message.success(msg);
              this.$emit("closeDialog");
              this.$emit("getNewPage");
            }
          });
        } else {
          return false;
        }
      });
    },

    changeType(val) {
      this.industryArr1.forEach((item) => {
        if (item.code == val) {
          this.form.subClassCompleteName = item;
        }
      });
    },

    openThreeType() {
      this.ThreeTypeDialogVisible = true;
    },

    // dataObj(val) {
    //   console.log(val);
    //   this.form.deptValue=val.label;
    //   this.form.deptId=val.id;
    // },

    changeSourceDepartment() {
      this.dispatchDialogVisible = true;
    },

    // threeTypeMsg(data) {
    //   console.log(data);
    //   this.form.subClassCompleteName = data.completeName;
    //   this.form.subClassName = data.name;
    //   this.form.subClassCode = data.code;
    // },
  },
};
</script>

<style lang='scss' scoped>
.buttomBtn {
  margin-top: 15px;
}

/deep/ .categorySupName .el-form-item__label {
  padding: 0px 2px 0px 2px;
}
</style>
